#!/usr/bin/python
"""
ptb-style trees (multi-line tree) have no blank lines
so we add one as a tree boundry.
"""

import sys, os

lines=[]
for l in sys.stdin.readlines():
	lines.append(l)
sentstr="".join(lines)

depth=0
chars = []
for c in sentstr:
	if c =='(':
		depth += 1
	if c == ')':
		depth -= 1
	chars.append(c)
	if depth == 0 and c == ')':
		chars.append('\n')

sys.stdout.write("".join(chars))
